package gui.domain;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JSplitPane;

public class Domainview extends JPanel {

	Editorview editorview;
	Htmlview htmlview;
	JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
	Boolean b;
	
	public Domainview() {
		oppstart();		
	}

	private void oppstart() {
		b = true;
		setLayout(new BorderLayout());
		split.setLeftComponent(editorview = new Editorview());
		split.setRightComponent(htmlview = new Htmlview());
		add(split);
	}
	
	public void setDividers() {
		split.setDividerLocation(0.5);
	}

	public void open() {		
		editorview.load();		
	}

	public void save() {
		editorview.save();		
	}

	public void paste() {
		editorview.paste();		
	}

	public void testhtml() {
		htmlview.setText(editorview.getText());		
	}

	public void changeview() {
		if (b==true){ 
			removeAll();
			setLayout(new BorderLayout());
			add(editorview=new Editorview());
			System.out.println("SKIFT" +" "  + b);
			updateUI();
			b=false;
			}
		
		else{
			removeAll();
			oppstart();
			System.out.println("SKIFT" + b);
			updateUI();
			b = true;
		}
		
	}

}
